export default {
  trimSpace: function(str) {
    return str.replace(/\s/g, '');
  },
  throttle: function(fn, delay) {
    var begin = new Date().getTime(),
      t = null;

    return function() {
      var args = arguments,
        _self = this,
        cur = new Date().getTime();

      clearTimeout(t);
      if (cur - begin >= delay) {
        fn.apply(_self, args);
        begin = cur;
      }else{
        t = setTimeout(()=>{
          fn.apply(_self, args);
        },delay);
      }
    }
  }
}
